//
//  TopCollectionViewCell.swift
//  RoundCatPlay2
//
//  Created by 姜澎 on 2019/10/18.
//  Copyright © 2019 jiangpeng. All rights reserved.
//

import UIKit
import SnapKit
class TopCollectionViewCell: UICollectionViewCell {
    
    var cellModel:TopCellModel? {
        didSet {
            self.topImageView.image = UIImage(named: cellModel?.imageV ?? "...")
            self.imageName.text = cellModel?.imagName
        }
    }
    
    private lazy var topImageView: UIImageView = {
        let image = UIImageView()
        image.contentMode = .scaleAspectFit
        return image
    }()
    
    private lazy var imageName: UILabel = {
        let name = UILabel()
        name.textAlignment = .center
        name.font = UIFont.systemFont(ofSize: 11)
        return name
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(topImageView)
        addSubview(imageName)
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}

// 设置UI
extension TopCollectionViewCell {
    func setUI() {
        self.topImageView.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(50)
        }
        self.imageName.snp.makeConstraints { (make) in
            make.top.equalTo(self.topImageView.snp_bottom).offset(10)
            make.height.equalTo(10)
            make.bottom.equalTo(0)
            make.width.equalTo(self.topImageView.snp.width)
        }
    }
}
